package com.sky.pay.uitls;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @author yangsk
 */
public class HttpUtil {
    public static String covertData(HttpServletRequest request) throws IOException {
        BufferedReader reader = null;
        try{
            StringBuffer result = new StringBuffer();
            String line =null;
            reader = request.getReader();
            //读取数据，将结果存入result
            while ((line=reader.readLine())!=null){
                if(result.length()>0){
                    result.append("\n");
                }
                result.append(line);
            }
            return result.toString();
        }catch (IOException e){
            new RuntimeException("从request对象中读取数据异常",e);
        }finally {
            reader.close();
        }
        return null;
    }
}
